package com.gxa.service.shezhiservice.Impl;

import com.gxa.common.R;
import com.gxa.mapper.shezhimapper.JiLiangDanWei46Mapper;
import com.gxa.pojo.JiLiangDanWei;
import com.gxa.pojo.JieSuanWay;
import com.gxa.service.shezhiservice.JiLiangDanWei46Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JiLiangDanWei46ServiceImpl implements JiLiangDanWei46Service {

    @Autowired
    private JiLiangDanWei46Mapper jiLiangDanWei46Mapper;
    @Override
    public R selectAllJiLiangDanWeiForPage(int page, int size) {
        R r = new R();
        int index = (page - 1)*size;
        List<JiLiangDanWei> jiLiangDanWeis = jiLiangDanWei46Mapper.selectAllJiLiangDanWeiForPage(index,size);
        if (jiLiangDanWeis != null){
            r.setCode(200);
            r.setMsg("查询成功！");
            r.setData(jiLiangDanWeis);
        }
        return r;
    }


    @Override
    public R insertJiLiangDanWei(JiLiangDanWei jiLiangDanWei) {
        R r = new R();
        int res =  jiLiangDanWei46Mapper.insertJiLiangDanWei(jiLiangDanWei);
        r.setCode(500);
        r.setMsg("新增失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("新增成功");
        }
        return r;
    }

    @Override
    public R updateJiLiangDanWeiById(JiLiangDanWei jiLiangDanWei) {
        R r = new R();
        int res =  jiLiangDanWei46Mapper.updateJiLiangDanWeiById(jiLiangDanWei);
        r.setCode(500);
        r.setMsg("更新失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("更新成功");
        }
        return r;
    }

    @Override
    public R deleteJiLiangDanWeiById(int id) {
        R r = new R();
        int res = jiLiangDanWei46Mapper.deleteJiLiangDanWeiById(id);
        r.setCode(500);
        r.setMsg("删除失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("删除成功");
        }
        return r;
    }

}
